<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		
		<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
	</head>
	<body>
		<div id="app">
			<input type="text" v-model="num1" />
			<select v-model="op">
				<option>+</option>
				<option>-</option>
				<option>*</option>
				<option>/</option>
			</select>
			<input type="text" v-model="num2"/>
			<button type="button"  v-on:click="cal">=</button>
			<input type="text"   v-model="result" />
		</div>
		
		
		<script>
	
			// 练习:实现加减乘除的计算器
			var app = Vue.createApp({
				data(){
					return {
						num1:'',
						num2:'',
						result:'',
						op:''
					}
				},
				methods:{
					cal:function()
					{
						console.log("执行计算")
						
						console.log(this.op)
						
						var x = parseInt(this.num1);
						var y = parseInt(this.num2);
						
						if(this.op=='+')
						{
							var z = x+y ;
						}
						else if(this.op=='-')
						{
							var z = x-y ;
						}
						else if(this.op=='*')
						{
							var z = x*y ;
						}
						else if(this.op=='/')
						{
							var z = x/y ;
						}
						this.result = z;
						
					}
					
				},
			
			});
			
			var vm = app.mount("#app")
		</script>
	</body>
</html>
